from django.db import models
from django.utils import timezone
from django.contrib.auth.models import AbstractUser
import uuid
# 导入信号
from django.db.models.signals import pre_delete
from django.dispatch.dispatcher import receiver


# Create your models here.


class StaffInfoModel(models.Model):
    """
    员工信息表格
    """
    name = models.CharField(max_length=20, null=False, blank=False, verbose_name="员工姓名",
                            help_text="员工姓名")
    nickname = models.CharField(max_length=20, null=False, blank=False, verbose_name="员工花名",
                                help_text="员工花名")
    phone = models.CharField(max_length=20, unique=True, null=False, blank=False, verbose_name="员工手机",
                             help_text="员工手机")
    password = models.CharField(max_length=200, null=False, blank=False, verbose_name="员工密码",
                                help_text="员工密码")
    birthday = models.CharField(max_length=20, null=False, blank=False, verbose_name="员工生日",
                                help_text="员工生日")
    gender = models.CharField(default="男", max_length=10, null=True, blank=True, verbose_name="员工性别",
                              help_text="员工性别")
    post = models.CharField(max_length=20, null=True, blank=True, verbose_name="员工职位", help_text="员工职位")
    join_date = models.CharField(max_length=20, null=True, blank=True, verbose_name="入职时间", help_text="入职时间")
    is_active = models.BooleanField(default=False, null=True, blank=True, verbose_name="是否激活", help_text="是否激活")
    expand_json = models.JSONField(null=True, blank=True, verbose_name="扩展字段",
                                   help_text="扩展字段：可能有其他新业务，现在预留一个存储json数据的字段")
    created_time = models.CharField(max_length=20, null=True, blank=True, verbose_name="创建时间", help_text="创建时间")

    class Meta:
        verbose_name = '员工信息表格'
        verbose_name_plural = verbose_name

    def __str__(self):
        return str(self.id)


class PostInfoModel(models.Model):
    """
    职位信息表格
    """
    name = models.CharField(max_length=20, unique=True, null=False, blank=False, verbose_name="职位名称",
                            help_text="职位名称")
    desc = models.CharField(max_length=100, null=True, blank=True, verbose_name="职位介绍", help_text="职位介绍")
    expand_json = models.JSONField(null=True, blank=True, verbose_name="扩展字段",
                                   help_text="扩展字段：可能有其他新业务，现在预留一个存储json数据的字段")
    created_time = models.CharField(max_length=20, null=True, blank=True, verbose_name="创建时间",
                                    help_text="创建时间")

    class Meta:
        verbose_name = '职位信息表格'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name
